﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Antu.WebControls;
using Antu.Core.Components;
using Antu.Core.Services;
using System.Web.UI.WebControls;
using EluZSProvider;
using System.Web;
using System.Data;

namespace WebSys.UI.Control.ZhengShou
{
    public class HuoBiHuaBuChangXieYiControl : MPBasicTemplate
    {
        EluZSDataProvider _EluZSDataProvider = (EluZSDataProvider)ProviderService.ProviderServiceMange.GetProvider("EluZSProvider");
        public string userid = string.Empty;
        Button btnUpload, btn_Insert, Button2, Button1, Button3, Button5, FuJian, btn_zddr, Button4, Button7, btndel, btn_协议带入;
        ImageButton ImageButton1;
        LinkButton LinkButton1;
        Label Label1, Label2;
        TextBox txtZSJDH, txt补充协议;
        protected override void OnLoad(EventArgs e)
        {
            if (HttpContext.Current.Session["UserID"] == null)
            {
                Antu.Utilities.UtilitiesPage.AlertDialogClear("登录超时，请重新登录！", "window.parent.location.href('../login.aspx');");
            }
            else
            {
                userid = HttpContext.Current.Session["UserID"].ToString();
            }
            base.OnLoad(e);
            InitControl();
            MPPersistence Persistence1 = (MPPersistence)FindControl("Persistence1");
            Panel panel1 = (Panel)FindControl("panel1");
            if (!base.Page.IsPostBack)
            {
                Persistence1.Table = "zs_hbhxy";
                Persistence1.Key = "ID";
                Persistence1.KeyValue = HttpContext.Current.Request["id"];
                Persistence1.ConnStr = _EluZSDataProvider.GetConnectionString();
            }
            Persistence1.BindControl = panel1;
            BindData();
            IsLookPerson();
        }

        private void IsLookPerson()
        {
            string sql = "Select rolename from zs_role where id in (Select roleid from zs_user_in_role where userid = '" + userid + "')";
            DataTable dt = _EluZSDataProvider.GetTable(sql);
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["rolename"].ToString().Equals("查看人员"))
                    {
                        Button btn_Insert = (Button)FindControl("btn_Insert");
                        btn_Insert.Visible = false;
                    }
                }
            }
        }

        protected void InitControl()
        {
            Panel panel1 = (Panel)FindControl("panel1");
            TabControl tabConreol1 = (TabControl)panel1.FindControl("tabConreol1");
            TabPage TabPage1 = (TabPage)tabConreol1.FindControl("TabPage1");
            TabPage TabPage3 = (TabPage)tabConreol1.FindControl("TabPage3");
            TabPage TabPage6 = (TabPage)tabConreol1.FindControl("TabPage6");
            TabPage TabPage8 = (TabPage)tabConreol1.FindControl("TabPage8");

            txtZSJDH = (TextBox)TabPage1.FindControl("txtZSJDH");
            btnUpload = (Button)FindControl("btnUpload");
            btn_Insert = (Button)FindControl("btn_Insert");
            Button2 = (Button)FindControl("Button2");
            Button1 = (Button)FindControl("Button1");
            ImageButton1 = (ImageButton)FindControl("ImageButton1");
            Button7 = (Button)FindControl("Button7");
            btndel = (Button)FindControl("btndel");

            LinkButton1 = (LinkButton)FindControl("LinkButton1");
            Button3 = (Button)FindControl("Button3");
            Button5 = (Button)TabPage3.FindControl("Button5");
            Label1 = (Label)FindControl("Label1");
            Label2 = (Label)FindControl("Label2");
            FuJian = (Button)TabPage6.FindControl("FuJian");
            btn_zddr = (Button)FindControl("btn_zddr");
            Button4 = (Button)FindControl("Button4");
            txt补充协议 = (TextBox)TabPage8.FindControl("txt补充协议");
            btn_协议带入 = (Button)TabPage8.FindControl("btn_协议带入");

            btn_zddr.Click += new EventHandler(btn_zddr_Click);
            btnUpload.Click += new EventHandler(btnUpload_Click);
            Button2.Click += new EventHandler(BtnTijiao_Click);
            Button1.Click += new EventHandler(button1_Click);
            ImageButton1.Click += new ImageClickEventHandler(ImageButton1_Click);
            LinkButton1.Click += new EventHandler(linkButton1_Click);
            Button3.Click += new EventHandler(button3_Click);
            Button5.Click += new EventHandler(Button5_Click);
            FuJian.Click += new EventHandler(FuJian_Click);
            btn_Insert.Click += new EventHandler(btn_Insert_Click);
            Button4.Click += new EventHandler(Button4_Click);
            Button7.Click += new EventHandler(Button7_Click);
            btndel.Click += new EventHandler(btndel_Click);
            btn_协议带入.Click += new EventHandler(btn_协议带入_Click);
        }

        protected void btn_协议带入_Click(object sender, EventArgs e)
        {
            Panel panel1 = (Panel)FindControl("panel1");
            TabControl tabConreol1 = (TabControl)panel1.FindControl("tabConreol1");
            TabPage TabPage8 = (TabPage)tabConreol1.FindControl("TabPage8");
            TextBox txt补充小计 = (TextBox)TabPage8.FindControl("txt补充小计");
            TextBox txt补充过渡费 = (TextBox)TabPage8.FindControl("txt补充过渡费");
            TextBox txt补充特殊困难 = (TextBox)TabPage8.FindControl("txt补充特殊困难");
            TextBox txt补充住改非 = (TextBox)TabPage8.FindControl("txt补充住改非");
            TextBox txt补充其它 = (TextBox)TabPage8.FindControl("txt补充其它");
            TextBox txt补充预支补偿款 = (TextBox)TabPage8.FindControl("txt补充预支补偿款");
            TextBox txt补充货币补偿金额 = (TextBox)TabPage8.FindControl("txt补充货币补偿金额");
            TextBox txt补充产权调换房面积1 = (TextBox)TabPage8.FindControl("txt补充产权调换房面积1");
            TextBox txt补充产权调换房套数1 = (TextBox)TabPage8.FindControl("txt补充产权调换房套数1");
            TextBox txt补充产权调换房面积2 = (TextBox)TabPage8.FindControl("txt补充产权调换房面积2");
            TextBox txt补充产权调换房套数2 = (TextBox)TabPage8.FindControl("txt补充产权调换房套数2");
            TextBox txt补充产权调换房面积3 = (TextBox)TabPage8.FindControl("txt补充产权调换房面积3");
            TextBox txt补充产权调换房套数3 = (TextBox)TabPage8.FindControl("txt补充产权调换房套数3");
            TextBox txt经济适用房面积1 = (TextBox)TabPage8.FindControl("txt经济适用房面积1");
            TextBox txt经济适用房套数1 = (TextBox)TabPage8.FindControl("txt经济适用房套数1");
            TextBox txt补充姓名1 = (TextBox)TabPage8.FindControl("txt补充姓名1");
            TextBox txt补充身份证1 = (TextBox)TabPage8.FindControl("txt补充身份证1");
            TextBox txt补充房屋补偿款1 = (TextBox)TabPage8.FindControl("txt补充房屋补偿款1");
            TextBox txt补充补助费1 = (TextBox)TabPage8.FindControl("txt补充补助费1");
            TextBox txt补充人员1产权调换房面积1 = (TextBox)TabPage8.FindControl("txt补充人员1产权调换房面积1");
            TextBox txt补充人员1产权调换房套数1 = (TextBox)TabPage8.FindControl("txt补充人员1产权调换房套数1");
            TextBox txt补充人员1产权调换房面积2 = (TextBox)TabPage8.FindControl("txt补充人员1产权调换房面积2");
            TextBox txt补充人员1产权调换房套数2 = (TextBox)TabPage8.FindControl("txt补充人员1产权调换房套数2");
            TextBox txt补充人员1产权调换房面积3 = (TextBox)TabPage8.FindControl("txt补充人员1产权调换房面积3");
            TextBox txt补充人员1产权调换房套数3 = (TextBox)TabPage8.FindControl("txt补充人员1产权调换房套数3");
            TextBox txt补充人员1经济适用房面积 = (TextBox)TabPage8.FindControl("txt补充人员1经济适用房面积");
            TextBox txt补充人员1经济适用房套数 = (TextBox)TabPage8.FindControl("txt补充人员1经济适用房套数");
            TextBox txt补充人员1封闭金额 = (TextBox)TabPage8.FindControl("txt补充人员1封闭金额");
            TextBox txt补充姓名2 = (TextBox)TabPage8.FindControl("txt补充姓名2");
            TextBox txt补充身份证2 = (TextBox)TabPage8.FindControl("txt补充身份证2");
            TextBox txt补充房屋补偿款2 = (TextBox)TabPage8.FindControl("txt补充房屋补偿款2");
            TextBox txt补充补助费2 = (TextBox)TabPage8.FindControl("txt补充补助费2");
            TextBox txt补充人员2产权调换房面积1 = (TextBox)TabPage8.FindControl("txt补充人员2产权调换房面积1");
            TextBox txt补充人员2产权调换房套数1 = (TextBox)TabPage8.FindControl("txt补充人员2产权调换房套数1");
            TextBox txt补充人员2产权调换房面积2 = (TextBox)TabPage8.FindControl("txt补充人员2产权调换房面积2");
            TextBox txt补充人员2产权调换房套数2 = (TextBox)TabPage8.FindControl("txt补充人员2产权调换房套数2");
            TextBox txt补充人员2产权调换房面积3 = (TextBox)TabPage8.FindControl("txt补充人员2产权调换房面积3");
            TextBox txt补充人员2产权调换房套数3 = (TextBox)TabPage8.FindControl("txt补充人员2产权调换房套数3");
            TextBox txt补充人员2经济适用房面积 = (TextBox)TabPage8.FindControl("txt补充人员2经济适用房面积");
            TextBox txt补充人员2经济适用房套数 = (TextBox)TabPage8.FindControl("txt补充人员2经济适用房套数");
            TextBox txt补充人员2封闭金额 = (TextBox)TabPage8.FindControl("txt补充人员2封闭金额");
            TextBox txt补充姓名3 = (TextBox)TabPage8.FindControl("txt补充姓名3");
            TextBox txt补充身份证3 = (TextBox)TabPage8.FindControl("txt补充身份证3");
            TextBox txt补充房屋补偿款3 = (TextBox)TabPage8.FindControl("txt补充房屋补偿款3");
            TextBox txt补充补助费3 = (TextBox)TabPage8.FindControl("txt补充补助费3");
            TextBox txt补充人员3产权调换房面积1 = (TextBox)TabPage8.FindControl("txt补充人员3产权调换房面积1");
            TextBox txt补充人员3产权调换房套数1 = (TextBox)TabPage8.FindControl("txt补充人员3产权调换房套数1");
            TextBox txt补充人员3产权调换房面积2 = (TextBox)TabPage8.FindControl("txt补充人员3产权调换房面积2");
            TextBox txt补充人员3产权调换房套数2 = (TextBox)TabPage8.FindControl("txt补充人员3产权调换房套数2");
            TextBox txt补充人员3产权调换房面积3 = (TextBox)TabPage8.FindControl("txt补充人员3产权调换房面积3");
            TextBox txt补充人员3产权调换房套数3 = (TextBox)TabPage8.FindControl("txt补充人员3产权调换房套数3");
            TextBox txt补充人员3经济适用房面积 = (TextBox)TabPage8.FindControl("txt补充人员3经济适用房面积");
            TextBox txt补充人员3经济适用房套数 = (TextBox)TabPage8.FindControl("txt补充人员3经济适用房套数");
            TextBox txt补充人员3封闭金额 = (TextBox)TabPage8.FindControl("txt补充人员3封闭金额");
            TextBox txt补充姓名4 = (TextBox)TabPage8.FindControl("txt补充姓名4");
            TextBox txt补充身份证4 = (TextBox)TabPage8.FindControl("txt补充身份证4");
            TextBox txt补充房屋补偿款4 = (TextBox)TabPage8.FindControl("txt补充房屋补偿款4");
            TextBox txt补充补助费4 = (TextBox)TabPage8.FindControl("txt补充补助费4");
            TextBox txt补充人员4产权调换房面积1 = (TextBox)TabPage8.FindControl("txt补充人员4产权调换房面积1");
            TextBox txt补充人员4产权调换房套数1 = (TextBox)TabPage8.FindControl("txt补充人员4产权调换房套数1");
            TextBox txt补充人员4产权调换房面积2 = (TextBox)TabPage8.FindControl("txt补充人员4产权调换房面积2");
            TextBox txt补充人员4产权调换房套数2 = (TextBox)TabPage8.FindControl("txt补充人员4产权调换房套数2");
            TextBox txt补充人员4产权调换房面积3 = (TextBox)TabPage8.FindControl("txt补充人员4产权调换房面积3");
            TextBox txt补充人员4产权调换房套数3 = (TextBox)TabPage8.FindControl("txt补充人员4产权调换房套数3");
            TextBox txt补充人员4经济适用房面积 = (TextBox)TabPage8.FindControl("txt补充人员4经济适用房面积");
            TextBox txt补充人员4经济适用房套数 = (TextBox)TabPage8.FindControl("txt补充人员4经济适用房套数");
            TextBox txt补充人员4封闭金额 = (TextBox)TabPage8.FindControl("txt补充人员4封闭金额");
            txt补充协议.Text = "";
            string text = "经征收当事人充分协商，就本协议未尽事宜达成如下补充协议：";
            text += " 一、甲方现金支付下列费用，合计"+txt补充小计.Text+"元。";
            text += " 1、提前搬家过渡费"+txt补充过渡费.Text+"元；";
            text += " 2、特殊困难补助费"+txt补充特殊困难.Text+"元；";
            text += " 3、住改非补差费"+txt补充住改非.Text+"元；";
            text += " 4、其它"+txt补充其它.Text+"元；";
            text += " 二、同意将预支补偿款"+txt补充预支补偿款.Text+"元，在房屋补偿中扣除。";
            text += @" 三、房屋所有权人已充分了解申购政策，保证所提供的申购材料符合申购要求。同意将房屋货币补偿金额：
                       "+txt补充货币补偿金额.Text+"元进行封闭，用以定购产权调换房"+txt补充产权调换房面积1.Text+"㎡左右套型"+txt补充产权调换房套数1.Text+"套，"+txt补充产权调换房面积2.Text+"㎡左右套型"+txt补充产权调换房套数2.Text+"套，"+txt补充产权调换房面积3.Text+"㎡左右套型"+txt补充产权调换房套数3.Text+"套；经济适用房"+txt经济适用房面积1.Text+"㎡左右套型"+txt经济适用房套数1.Text+"套。 ";
            text += " 四、因房屋所有权共有，经家庭协商，对该房屋征收补偿具结及申购如下：";

            text += @" 1、姓名："+txt补充姓名1.Text+" 身份证号："+txt补充身份证1.Text+"房屋补偿款："+txt补充房屋补偿款1.Text+"元，补助费："+txt补充补助费1.Text+"元 产权调换房"+txt补充人员1产权调换房面积1.Text+"㎡左右套型"+txt补充人员1产权调换房套数1.Text+"套，"+txt补充人员1产权调换房面积2.Text+"㎡左右套型"+txt补充人员1产权调换房套数2.Text+"套，"+txt补充人员1产权调换房面积3.Text+"㎡左右套型"+txt补充人员1产权调换房套数3.Text+"套；经济适用房"+txt补充人员1经济适用房面积.Text+"㎡左右套型"+txt补充人员1经济适用房套数.Text+"套。封闭金额："+txt补充人员1封闭金额.Text+"元";


            text += @"2、姓名："+txt补充姓名2.Text+"身份证号："+txt补充身份证2.Text+"房屋补偿款："+txt补充房屋补偿款2.Text+"元，补助费："+txt补充补助费2.Text+"元  产权调换房"+txt补充人员2产权调换房面积1.Text+"㎡左右套型"+txt补充人员2产权调换房套数1.Text+"套，"+txt补充人员2产权调换房面积2.Text+"㎡左右套型"+txt补充人员2产权调换房套数2.Text+"套，"+txt补充人员2产权调换房面积3.Text+"㎡左右套型"+txt补充人员2产权调换房套数3.Text+"套； 经济适用房"+txt补充人员2经济适用房面积.Text+"㎡左右套型"+txt补充人员2经济适用房套数.Text+"套。<br />封闭金额："+txt补充人员2封闭金额.Text+"元";


            text += @" 3、姓名："+txt补充姓名3.Text+" 身份证号："+txt补充身份证3.Text+"房屋补偿款："+txt补充房屋补偿款3.Text+"元，补助费："+txt补充补助费3.Text+"元   产权调换房"+txt补充人员3产权调换房面积1.Text+"㎡左右套型"+txt补充人员3产权调换房套数1.Text+"套，"+txt补充人员3产权调换房面积2.Text+"㎡左右套型"+txt补充人员3产权调换房套数2.Text+"套，"+txt补充人员3产权调换房面积3.Text+"㎡左右套型"+txt补充人员3产权调换房套数3.Text+"套； 经济适用房"+txt补充人员3经济适用房面积.Text+"㎡左右套型"+txt补充人员3经济适用房套数.Text+"套。<br />封闭金额："+txt补充人员3封闭金额.Text+"元";


            text += @" 4、姓名："+txt补充姓名4.Text+" 身份证号："+txt补充身份证4.Text+"房屋补偿款："+txt补充房屋补偿款4.Text+"元，补助费："+txt补充补助费4.Text+"元   产权调换房"+txt补充人员4产权调换房面积1.Text+"㎡左右套型"+txt补充人员4产权调换房套数1.Text+"套，"+txt补充人员4产权调换房面积2.Text+"㎡左右套型"+txt补充人员4产权调换房套数2.Text+"套，"+txt补充人员4产权调换房面积3.Text+"㎡左右套型"+txt补充人员4产权调换房套数3.Text+"套；经济适用房"+txt补充人员4经济适用房面积.Text+"㎡左右套型"+txt补充人员4经济适用房套数.Text+"套。封闭金额："+txt补充人员4封闭金额.Text+"元";

            txt补充协议.Text = text ;
                        
        }

          /// <summary>
          ///  退回事件
          /// </summary>
          /// <param name="sender"></param>
          /// <param name="e"></param>
        protected void btndel_Click(object sender, EventArgs e)
        {
            //string strID = base.Page.Request["ID"];
            //if (!string.IsNullOrEmpty(strID))
            //{
            //    string sql = "Delete From zs_hbhxy Where Id='" + strID + "'";
            //    _EluZSDataProvider.RunSqlNon(sql);
            //    Page.ClientScript.RegisterStartupScript(this.GetType(), "sctj1", "<script>alert(删除成功！);window.location.href('HuoBiHuaList.aspx?PID=" + base.Page.Request["PID"] + "&query=hbba');</script>");
            // }
            if (btndel.Text == "退回修改")
            {
                string sql = "update zs_hbhxy set 是否退回 = '1' where id = '" + base.Page.Request["ID"] + "'";
                _EluZSDataProvider.RunSqlNon(sql);
                btndel.Text = "已退回";
                btn_Insert.Visible = false;
                Button4.Visible = false;
                Button3.Visible = false;
                Button2.Visible = false;
                Button1.Visible = false;
                Button7.Visible = false;
            }
            else if (btndel.Text == "已退回")
            {
                string sql = "update zs_hbhxy set 是否退回 = '0' where id = '" + base.Page.Request["ID"] + "'";
                _EluZSDataProvider.RunSqlNon(sql);
                btndel.Text = "退回修改";
                btn_Insert.Visible = true;
                Button4.Visible = true;
                Button3.Visible = true;
                Button2.Visible = true;
                Button1.Visible = true;
                Button7.Visible = true;
            }
        }

        //自动代入
        protected void btn_zddr_Click(object sender, EventArgs e)
        {
            zddr();
        }
        protected void zddr() 
        {
            Panel panel1 = (Panel)FindControl("panel1");
            TabControl tabConreol1 = (TabControl)panel1.FindControl("tabConreol1");
            TabPage TabPage3 = (TabPage)tabConreol1.FindControl("TabPage3");
            TabPage TabPage5 = (TabPage)tabConreol1.FindControl("TabPage5");
            TabPage TabPage9 = (TabPage)tabConreol1.FindControl("TablePage9");
            TextBox txtTextBox121 = (TextBox)TabPage3.FindControl("txtTextBox121");
            TextBox txtTextBox17 = (TextBox)TabPage3.FindControl("txtTextBox17");
            TextBox txtTextBox18 = (TextBox)TabPage3.FindControl("txtTextBox18");
            TextBox txtTextBox19 = (TextBox)TabPage3.FindControl("txtTextBox19");
            TextBox txtTextBox20 = (TextBox)TabPage3.FindControl("txtTextBox20");
            TextBox txtTextBox21 = (TextBox)TabPage3.FindControl("txtTextBox21");
            TextBox txtTextBox22 = (TextBox)TabPage3.FindControl("txtTextBox22");
            TextBox txtTextBox23 = (TextBox)TabPage3.FindControl("txtTextBox23");
            TextBox txtTextBox16 = (TextBox)TabPage3.FindControl("txtTextBox16");
            TextBox txtTextBox94 = (TextBox)TabPage9.FindControl("txtTextBox94");
            TextBox txtTextBox95 = (TextBox)TabPage9.FindControl("txtTextBox95");
            TextBox txtTextBox99 = (TextBox)TabPage9.FindControl("txtTextBox99");
            TextBox txtTextBox5 = (TextBox)TabPage3.FindControl("txtTextBox5");
            TextBox txtTextBox68 = (TextBox)TabPage5.FindControl("txtTextBox68");
            TextBox txtTextBox69 = (TextBox)TabPage5.FindControl("txtTextBox69");
            TextBox txtTextBox25 = (TextBox)TabPage3.FindControl("txtTextBox25");
            TextBox txtTextBox24 = (TextBox)TabPage3.FindControl("txtTextBox24");
            TextBox txtTextBox126 = (TextBox)TabPage3.FindControl("txtTextBox126");
            TextBox txtTextBox73 = (TextBox)TabPage5.FindControl("txtTextBox73");
            TextBox txtTextBox85 = (TextBox)TabPage5.FindControl("txtTextBox85");

            #region 原错误代入
            //            string sql = @"Select Zs_Zzbcjfenhu.*, Zs_Zsperson.*,zs_project.*
//  From Zs_Zzbcjfenhu, Zs_Zsperson,zs_project
// Where Zs_Zzbcjfenhu.Zspid = '" + Page.Request["PERSONID"] + @"'
//   And Zs_Zsperson.Id = Zs_Zzbcjfenhu.Zspid
//   And Zs_Zzbcjfenhu.Pid = '" + Page.Request["PID"] + @"'
//   And zs_project.id = (Select pid From zs_prono Where Id = Zs_Zzbcjfenhu.Pid )";
//            DataTable dt = _EluZSDataProvider.GetDTTable(sql);
//            if (dt.Rows.Count == 1)
//            {
//                //产权人补偿款
//                if (txtTextBox21.Text=="")
//                {
//                    txtTextBox21.Text = dt.Rows[0]["ZZ产权人补偿款"].ToString();
//                    Page.ClientScript.RegisterStartupScript(this.GetType(), "1", "<script>SetMoneyRelation('txtTextBox21','txtTextBox20')</script>");
//                }
//                //承租人补偿款
//                if (txtTextBox23.Text=="")
//                {
//                    txtTextBox23.Text = dt.Rows[0]["ZZ承租人补偿款"].ToString();
//                    Page.ClientScript.RegisterStartupScript(this.GetType(), "2", "<script>SetMoneyRelation('txtTextBox23','txtTextBox22')</script>");
//                }
                
//                if (!string.IsNullOrEmpty(txtTextBox21.Text) && !string.IsNullOrEmpty(txtTextBox23.Text))
//                {
//                    txtTextBox19.Text = (Convert.ToInt32(txtTextBox21.Text) + Convert.ToInt32(txtTextBox23.Text)).ToString();
//                    Page.ClientScript.RegisterStartupScript(this.GetType(), "3", "<script>SetMoneyRelation('txtTextBox19','txtTextBox18')</script>");
//                    txtTextBox121.Text = (Convert.ToInt32(txtTextBox21.Text) + Convert.ToInt32(txtTextBox23.Text)).ToString();
//                    Page.ClientScript.RegisterStartupScript(this.GetType(), "4", "<script>SetMoneyRelation('txtTextBox121','txtTextBox17')</script>");
//                }
//                //评估机构 此处带错
//                if (txtTextBox16.Text == "")
//                {
//                    txtTextBox16.Text = dt.Rows[0]["概算评估机构"].ToString();
//                }
//                //甲方 征收部门
//                if (txtTextBox94.Text == "")
//                {
//                    txtTextBox94.Text = txtTextBox5.Text;
//                }
//                //乙方 被征收人
//                if (txtTextBox95.Text == "")
//                {
//                    txtTextBox95.Text = dt.Rows[0]["产权人"].ToString();
//                }
//                //乙方 证件号
//                if (txtTextBox99.Text == "")
//                {
//                    txtTextBox99.Text = dt.Rows[0]["证件号"].ToString();
//                }
//            }
#endregion
            string strZspid = base.Page.Request["PERSONID"];
            string strPid = base.Page.Request["PID"];
            #region 产权人补偿款、承租人补偿款、装修补助费
            if (!string.IsNullOrEmpty(strZspid) && !string.IsNullOrEmpty(strPid))
            {
                string strCQRBCK = _EluZSDataProvider.GetString(@"Select nvl(Sum(to_number(nvl(replace(ZZ产权人补偿款,'\\',''),0))+
to_number(nvl(replace(YY产权人补偿款,'\\',''),0))+
to_number(nvl(replace(FYY产权人补偿款,'\\',''),0))+
--to_number(nvl(replace(ZS产权人补偿款,'\\',''),0))+
to_number(nvl(replace(ZGF产权人补偿款,'\\',''),0))),0) 产权人补偿款
From zs_zzbcjfenhu Where pid='" + strPid + "' And zspid='" + strZspid + "'");
                string strCZRBCK = _EluZSDataProvider.GetString(@"Select nvl(Sum(to_number(nvl(replace(ZZ承租人补偿款,'\\',''),0))+
to_number(nvl(replace(YY承租人补偿款,'\\',''),0))+
to_number(nvl(replace(FYY承租人补偿款,'\\',''),0))+
--to_number(nvl(replace(ZS承租人补偿款,'\\',''),0))+
to_number(nvl(replace(ZGF承租人补偿款,'\\',''),0))),0) 承租人补偿款
From zs_zzbcjfenhu Where pid='" + strPid + "' And zspid='" + strZspid + "'");
                string strZSBZF = _EluZSDataProvider.GetString(@"Select nvl(Sum(to_number(nvl(replace(ZS产权人补偿款,'\\',''),0))+
to_number(nvl(replace(ZS承租人补偿款,'\\',''),0))),0) 装修补助费
From zs_zzbcjfenhu Where pid='" + strPid + "' And zspid='" + strZspid + "'");
                string strZBCK = _EluZSDataProvider.GetString(@"Select nvl(sum(to_number(nvl(replace(ZZ产权人补偿款,'\\',''),0))+
to_number(nvl(replace(YY产权人补偿款,'\\',''),0))+
to_number(nvl(replace(FYY产权人补偿款,'\\',''),0))+
--to_number(nvl(replace(ZS产权人补偿款,'\\',''),0))+
to_number(nvl(replace(ZGF产权人补偿款,'\\',''),0))+
to_number(nvl(replace(ZZ承租人补偿款,'\\',''),0))+
to_number(nvl(replace(YY承租人补偿款,'\\',''),0))+
to_number(nvl(replace(FYY承租人补偿款,'\\',''),0))+
--to_number(nvl(replace(ZS承租人补偿款,'\\',''),0))+
to_number(nvl(replace(ZGF承租人补偿款,'\\',''),0))),0) 总补偿款
From zs_zzbcjfenhu Where pid='" + strPid + "' And zspid='" + strZspid + "'");
                if (string.IsNullOrEmpty(txtTextBox21.Text.Trim())) 
                {
                    txtTextBox21.Text = strCQRBCK;
                    base.Page.ClientScript.RegisterStartupScript(this.GetType(), "11111", "<script>SetMoneyRelation('txtTextBox21','txtTextBox20')</script>");
                }
                if (string.IsNullOrEmpty(txtTextBox23.Text.Trim()))
                {
                    txtTextBox23.Text = strCZRBCK;
                    base.Page.ClientScript.RegisterStartupScript(this.GetType(), "22222", "<script>SetMoneyRelation('txtTextBox23','txtTextBox22')</script>");
                }
                if (string.IsNullOrEmpty(txtTextBox19.Text.Trim()))
                {
                    txtTextBox19.Text = strZBCK;
                    base.Page.ClientScript.RegisterStartupScript(this.GetType(), "33333", "<script>SetMoneyRelation('txtTextBox19','txtTextBox18')</script>");
                }
                if (string.IsNullOrEmpty(txtTextBox121.Text.Trim()))
                {
                    txtTextBox121.Text = strZBCK;
                    base.Page.ClientScript.RegisterStartupScript(this.GetType(), "44444", "<script>SetMoneyRelation('txtTextBox121','txtTextBox17')</script>");
                }
                if (string.IsNullOrEmpty(txtTextBox126.Text.Trim()))
                {
                    txtTextBox126.Text = strZSBZF;
                }
            }
            #endregion
            #region 评估机构 甲乙方
            if (!string.IsNullOrEmpty(strPid))
            {
                if (string.IsNullOrEmpty(txtTextBox16.Text.Trim())) { txtTextBox16.Text = _EluZSDataProvider.GetString("Select 已通过征收评估机构 From zs_prono Where Id='" + strPid + "'"); }
                if (string.IsNullOrEmpty(txtTextBox94.Text.Trim())) { txtTextBox94.Text = _EluZSDataProvider.GetString("Select 征收部门 From zs_project Where Id In (Select pid From zs_prono Where Id='" + strPid + "')"); }
            }
            if (!string.IsNullOrEmpty(strZspid)) {
                if (string.IsNullOrEmpty(txtTextBox95.Text.Trim())) { txtTextBox95.Text = _EluZSDataProvider.GetString("Select 产权人 From zs_zsperson Where Id='" + strZspid + "'"); }
                if (string.IsNullOrEmpty(txtTextBox99.Text.Trim())) { txtTextBox99.Text = _EluZSDataProvider.GetString("Select 证件号 From zs_zsperson Where Id='" + strZspid + "'"); }
            }
            #endregion
            #region 代入房屋结构
            if (string.IsNullOrEmpty(txtTextBox68.Text.Trim()))
            {
                txtTextBox68.Text = _EluZSDataProvider.GetString(@"Select keyname From zs_params Where keyvalue In (Select 房屋结构 From zs_zsperson Where Id = '" + strZspid + "') And name = '结构等级'");
            }
            #endregion
            #region 代入房屋用途
            if (string.IsNullOrEmpty(txtTextBox69.Text.Trim()))
            {
                txtTextBox69.Text = _EluZSDataProvider.GetString(@"Select keyname From zs_params Where keyvalue In (Select 房屋用途 From zs_zsperson Where Id = '" + strZspid + "') And name = '国有土地使用证证载用途'");
            }
            #endregion
            #region 过度、拆迁补助费
            string gd = _EluZSDataProvider.GetString("Select nvl(replace(房屋建筑面积,'\',''),0) from zs_zsperson  where id = '" + strZspid + "' ");
            if (!string.IsNullOrEmpty(gd))
            {
                double mj = Convert.ToDouble(gd);
                double jsgd = (mj * 28 * 12);
                if (jsgd <= 600)
                {
                    jsgd = 600;
                }
                if (string.IsNullOrEmpty(txtTextBox25.Text.Trim()))
                {
                    txtTextBox25.Text = jsgd.ToString();
                }
                double jszq = (mj * 50);
                if (jszq <= 1000)
                {
                    jszq = 1000;
                }
                if (string.IsNullOrEmpty(txtTextBox24.Text.Trim()))
                {
                    txtTextBox24.Text = jszq.ToString();
                }
            }
            #endregion
            #region 代入产权面积、土地面积
            if (string.IsNullOrEmpty(txtTextBox73.Text.Trim())) { txtTextBox73.Text = _EluZSDataProvider.GetString("Select 房屋建筑面积 From zs_zsperson Where Id='" + strZspid + "'"); }
            if (string.IsNullOrEmpty(txtTextBox85.Text.Trim())) { txtTextBox85.Text = _EluZSDataProvider.GetString("Select 土地分摊面积 From zs_zsperson Where Id='" + strZspid + "'"); }
            #endregion
            #region 以下代码已转移到JS中

            ////管道煤气补助费
            //TextBox txtTextBox26 = (TextBox)TabPage3.FindControl("txtTextBox26");
            //if (txtTextBox26.Text=="")
            //{
            //    txtTextBox26.Text = "2800";
            //}
            ////管道煤气拥有户
            //TextBox txtTextBox89 = (TextBox)TabPage5.FindControl("txtTextBox89");
            //if (txtTextBox89.Text == "") 
            //{
            //    txtTextBox89.Text = "1";
            //}
            ////有线电话补助费
            //TextBox txtTextBox27 = (TextBox)TabPage3.FindControl("txtTextBox27");
            //if (txtTextBox27.Text=="")
            //{
            //    txtTextBox27.Text = "310";
            //}

            ////有线电话拥有户
            //TextBox txtTextBox86 = (TextBox)TabPage5.FindControl("txtTextBox86");
            //if (txtTextBox86.Text == "") 
            //{
            //    txtTextBox86.Text = "1";
            //}
            ////有线电视补助费
            //TextBox txtTextBox28 = (TextBox)TabPage3.FindControl("txtTextBox28");
            //if (txtTextBox28.Text == "")
            //{
            //    txtTextBox28.Text = "400";
            //}
            ////有线电视拥有户
            //TextBox txtTextBox87 = (TextBox)TabPage5.FindControl("txtTextBox87");
            //if (txtTextBox87.Text == "")
            //{
            //    txtTextBox87.Text = "1";
            //}
            ////宽带网补助费
            //TextBox txtTextBox30 = (TextBox)TabPage3.FindControl("txtTextBox30");
            //if (txtTextBox30.Text == "")
            //{
            //    txtTextBox30.Text = "400";
            //}
            ////宽带网拥有户
            //TextBox txtTextBox90 = (TextBox)TabPage5.FindControl("txtTextBox90");
            //if (txtTextBox90.Text == "")
            //{
            //    txtTextBox90.Text = "1";
            //}
            ////空调补助费
            //TextBox txtTextBox29 = (TextBox)TabPage3.FindControl("txtTextBox29");
            //if (txtTextBox29.Text == "")
            //{
            //    txtTextBox29.Text = "200";
            //}
            ////空调拥有户
            //TextBox txtTextBox88 = (TextBox)TabPage5.FindControl("txtTextBox88");
            //if (txtTextBox88.Text == "")
            //{
            //    txtTextBox88.Text = "1";
            //}
            ////太阳能补助费
            //TextBox txtTextBox31 = (TextBox)TabPage3.FindControl("txtTextBox31");
            //if (txtTextBox31.Text == "")
            //{
            //    txtTextBox31.Text = "200";
            //}
            ////太阳能拥有户
            //TextBox txtTextBox91 = (TextBox)TabPage5.FindControl("txtTextBox91");
            //if (txtTextBox91.Text == "")
            //{
            //    txtTextBox91.Text = "1";
            //}
            ////电容补助费
            //TextBox txtTextBox32 = (TextBox)TabPage3.FindControl("txtTextBox32");
            //if (txtTextBox32.Text == "")
            //{
            //    txtTextBox32.Text = "280";
            //}
            ////电容拥有户
            //TextBox txtTextBox92 = (TextBox)TabPage5.FindControl("txtTextBox92");
            //if (txtTextBox92.Text == "")
            //{
            //    txtTextBox92.Text = "8000";
            //}

            //#region 甲方向乙方支付

            //TextBox txtTextBox35 = (TextBox)TabPage3.FindControl("txtTextBox35");
            //if (txtTextBox35.Text != "")
            //{
            //    string[] sp = txtTextBox35.Text.Split(',');
            //    #region 判断输入的写法是逗号分隔
            //    if (sp.Length > 1)
            //    {
            //        int money = 0;
            //        for (int i = 0; i < sp.Length; i++)
            //        {
            //            if (sp[i].Equals("1"))
            //            {
            //                TextBox txtTextBox24 = (TextBox)TabPage3.FindControl("txtTextBox24");
            //                money = Convert.ToInt32(txtTextBox24.Text) + money;
            //            }
            //            if (sp[i].Equals("2"))
            //            {
            //                TextBox txtTextBox25 = (TextBox)TabPage3.FindControl("txtTextBox25");
            //                money = Convert.ToInt32(txtTextBox25.Text) + money;
            //            }
            //            if (sp[i].Equals("3"))
            //            {
            //                money = Convert.ToInt32(txtTextBox26.Text) + money;
            //            }
            //            if (sp[i].Equals("4"))
            //            {
            //                money = Convert.ToInt32(txtTextBox27.Text) + money;
            //            }
            //            if (sp[i].Equals("5"))
            //            {
            //                money = Convert.ToInt32(txtTextBox28.Text) + money;
            //            }
            //            if (sp[i].Equals("6"))
            //            {
            //                money = Convert.ToInt32(txtTextBox29.Text) + money;
            //            }
            //            if (sp[i].Equals("7"))
            //            {
            //                money = Convert.ToInt32(txtTextBox30.Text) + money;
            //            }
            //            if (sp[i].Equals("8"))
            //            {
            //                money = Convert.ToInt32(txtTextBox31.Text) + money;
            //            }
            //            if (sp[i].Equals("9"))
            //            {
            //                money = Convert.ToInt32(txtTextBox32.Text) + money;
            //            }
            //            if (sp[i].Equals("10"))
            //            {
            //                TextBox txtTextBox125 = (TextBox)TabPage3.FindControl("txtTextBox125");
            //                money = Convert.ToInt32(txtTextBox125.Text) + money;
            //            }
            //            if (sp[i].Equals("11"))
            //            {
            //                money = Convert.ToInt32(txtTextBox126.Text) + money;
            //            }
            //            if (sp[i].Equals("12"))
            //            {
            //                TextBox txtTextBox34 = (TextBox)TabPage3.FindControl("txtTextBox34");
            //                money = Convert.ToInt32(txtTextBox34.Text) + money;
            //            }
            //            if (sp[i].Equals("13"))
            //            {
            //                TextBox txtTextBox33 = (TextBox)TabPage3.FindControl("txtTextBox33");
            //                money = Convert.ToInt32(txtTextBox33.Text) + money;
            //            }
            //            if (sp[i].Equals("14"))
            //            {
            //                TextBox txtTextBox122 = (TextBox)TabPage3.FindControl("txtTextBox122");
            //                money = Convert.ToInt32(txtTextBox122.Text) + money;
            //            }
            //        }
            //        TextBox txtTextBox37 = (TextBox)TabPage3.FindControl("txtTextBox37");
            //        if (txtTextBox37.Text=="")
            //        {
            //            txtTextBox37.Text = money.ToString();
            //            Page.ClientScript.RegisterStartupScript(this.GetType(), "5", "<script>SetMoneyRelation('txtTextBox37','txtTextBox36')</script>");
            //        }

            //    }
            //    #endregion
            //    else
            //    {
            //        string[] sp1 = txtTextBox35.Text.Split('-');
            //        if (sp1.Length > 1)
            //        {
            //            string num = string.Empty;
            //            for (int i = Convert.ToInt32(sp1[0].ToString()); i <= Convert.ToInt32(sp1[1].ToString()); i++)
            //            {
            //                num += "," + i;
            //            }
            //            string[] sp2 = num.Split(',');
            //            if (sp2.Length > 1)
            //            {
            //                int money = 0;
            //                for (int i = 0; i < sp2.Length; i++)
            //                {
            //                    if (sp2[i].Equals("1"))
            //                    {
            //                        TextBox txtTextBox24 = (TextBox)TabPage3.FindControl("txtTextBox24");
            //                        money = Convert.ToInt32(txtTextBox24.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("2"))
            //                    {
            //                        TextBox txtTextBox25 = (TextBox)TabPage3.FindControl("txtTextBox25");
            //                        money = Convert.ToInt32(txtTextBox25.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("3"))
            //                    {
            //                        money = Convert.ToInt32(txtTextBox26.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("4"))
            //                    {
            //                        money = Convert.ToInt32(txtTextBox27.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("5"))
            //                    {
            //                        money = Convert.ToInt32(txtTextBox28.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("6"))
            //                    {
            //                        money = Convert.ToInt32(txtTextBox29.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("7"))
            //                    {
            //                        money = Convert.ToInt32(txtTextBox30.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("8"))
            //                    {
            //                        money = Convert.ToInt32(txtTextBox31.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("9"))
            //                    {
            //                        money = Convert.ToInt32(txtTextBox32.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("10"))
            //                    {
            //                        TextBox txtTextBox125 = (TextBox)TabPage3.FindControl("txtTextBox125");
            //                        money = Convert.ToInt32(txtTextBox125.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("11"))
            //                    {
            //                        money = Convert.ToInt32(txtTextBox126.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("12"))
            //                    {
            //                        TextBox txtTextBox34 = (TextBox)TabPage3.FindControl("txtTextBox34");
            //                        money = Convert.ToInt32(txtTextBox34.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("13"))
            //                    {
            //                        TextBox txtTextBox33 = (TextBox)TabPage3.FindControl("txtTextBox33");
            //                        money = Convert.ToInt32(txtTextBox33.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("14"))
            //                    {
            //                        TextBox txtTextBox122 = (TextBox)TabPage3.FindControl("txtTextBox122");
            //                        money = Convert.ToInt32(txtTextBox122.Text) + money;
            //                    }
            //                }
            //                TextBox txtTextBox37 = (TextBox)TabPage3.FindControl("txtTextBox37");
            //                if (txtTextBox37.Text=="")
            //                {
            //                    txtTextBox37.Text = money.ToString();
            //                    Page.ClientScript.RegisterStartupScript(this.GetType(), "5", "<script>SetMoneyRelation('txtTextBox37','txtTextBox36')</script>");
            //                }

            //            }
            //        }
            //    }

            //}
            //#endregion

            //#region 甲方向丙方支付

            //TextBox txtTextBox38 = (TextBox)TabPage3.FindControl("txtTextBox38");
            //if (txtTextBox38.Text != "")
            //{
            //    string[] sp = txtTextBox38.Text.Split(',');
            //    if (sp.Length > 1)
            //    {
            //        int money = 0;
            //        for (int i = 0; i < sp.Length; i++)
            //        {
            //            if (sp[i].Equals("1"))
            //            {
            //                TextBox txtTextBox24 = (TextBox)TabPage3.FindControl("txtTextBox24");
            //                money = Convert.ToInt32(txtTextBox24.Text) + money;
            //            }
            //            if (sp[i].Equals("2"))
            //            {
            //                TextBox txtTextBox25 = (TextBox)TabPage3.FindControl("txtTextBox25");
            //                money = Convert.ToInt32(txtTextBox25.Text) + money;
            //            }
            //            if (sp[i].Equals("3"))
            //            {
            //                money = Convert.ToInt32(txtTextBox26.Text) + money;
            //            }
            //            if (sp[i].Equals("4"))
            //            {
            //                money = Convert.ToInt32(txtTextBox27.Text) + money;
            //            }
            //            if (sp[i].Equals("5"))
            //            {
            //                money = Convert.ToInt32(txtTextBox28.Text) + money;
            //            }
            //            if (sp[i].Equals("6"))
            //            {
            //                money = Convert.ToInt32(txtTextBox29.Text) + money;
            //            }
            //            if (sp[i].Equals("7"))
            //            {
            //                money = Convert.ToInt32(txtTextBox30.Text) + money;
            //            }
            //            if (sp[i].Equals("8"))
            //            {
            //                money = Convert.ToInt32(txtTextBox31.Text) + money;
            //            }
            //            if (sp[i].Equals("9"))
            //            {
            //                money = Convert.ToInt32(txtTextBox32.Text) + money;
            //            }
            //            if (sp[i].Equals("10"))
            //            {
            //                TextBox txtTextBox125 = (TextBox)TabPage3.FindControl("txtTextBox125");
            //                money = Convert.ToInt32(txtTextBox125.Text) + money;
            //            }
            //            if (sp[i].Equals("11"))
            //            {
            //                money = Convert.ToInt32(txtTextBox126.Text) + money;
            //            }
            //            if (sp[i].Equals("12"))
            //            {
            //                TextBox txtTextBox34 = (TextBox)TabPage3.FindControl("txtTextBox34");
            //                money = Convert.ToInt32(txtTextBox34.Text) + money;
            //            }
            //            if (sp[i].Equals("13"))
            //            {
            //                TextBox txtTextBox33 = (TextBox)TabPage3.FindControl("txtTextBox33");
            //                money = Convert.ToInt32(txtTextBox33.Text) + money;
            //            }
            //            if (sp[i].Equals("14"))
            //            {
            //                TextBox txtTextBox122 = (TextBox)TabPage3.FindControl("txtTextBox122");
            //                money = Convert.ToInt32(txtTextBox122.Text) + money;
            //            }
            //        }
            //        TextBox txtTextBox40 = (TextBox)TabPage3.FindControl("txtTextBox40");
            //        if (txtTextBox40.Text=="")
            //        {

            //        txtTextBox40.Text = money.ToString();
            //        Page.ClientScript.RegisterStartupScript(this.GetType(), "6", "<script>SetMoneyRelation('txtTextBox40','txtTextBox39')</script>");
            //        }
            //    }
            //    else
            //    {
            //        string[] sp1 = txtTextBox38.Text.Split('-');
            //        if (sp1.Length > 1)
            //        {
            //            string num = string.Empty;
            //            for (int i = Convert.ToInt32(sp1[0].ToString()); i <= Convert.ToInt32(sp1[1].ToString()); i++)
            //            {
            //                num += "," + i;
            //            }
            //            string[] sp2 = num.Split(',');
            //            if (sp2.Length > 1)
            //            {
            //                int money = 0;
            //                for (int i = 0; i < sp2.Length; i++)
            //                {
            //                    if (sp2[i].Equals("1"))
            //                    {
            //                        TextBox txtTextBox24 = (TextBox)TabPage3.FindControl("txtTextBox24");
            //                        money = Convert.ToInt32(txtTextBox24.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("2"))
            //                    {
            //                        TextBox txtTextBox25 = (TextBox)TabPage3.FindControl("txtTextBox25");
            //                        money = Convert.ToInt32(txtTextBox25.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("3"))
            //                    {
            //                        money = Convert.ToInt32(txtTextBox26.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("4"))
            //                    {
            //                        money = Convert.ToInt32(txtTextBox27.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("5"))
            //                    {
            //                        money = Convert.ToInt32(txtTextBox28.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("6"))
            //                    {
            //                        money = Convert.ToInt32(txtTextBox29.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("7"))
            //                    {
            //                        money = Convert.ToInt32(txtTextBox30.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("8"))
            //                    {
            //                        money = Convert.ToInt32(txtTextBox31.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("9"))
            //                    {
            //                        money = Convert.ToInt32(txtTextBox32.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("10"))
            //                    {
            //                        TextBox txtTextBox125 = (TextBox)TabPage3.FindControl("txtTextBox125");
            //                        money = Convert.ToInt32(txtTextBox125.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("11"))
            //                    {
            //                        money = Convert.ToInt32(txtTextBox126.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("12"))
            //                    {
            //                        TextBox txtTextBox34 = (TextBox)TabPage3.FindControl("txtTextBox34");
            //                        money = Convert.ToInt32(txtTextBox34.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("13"))
            //                    {
            //                        TextBox txtTextBox33 = (TextBox)TabPage3.FindControl("txtTextBox33");
            //                        money = Convert.ToInt32(txtTextBox33.Text) + money;
            //                    }
            //                    if (sp2[i].Equals("14"))
            //                    {
            //                        TextBox txtTextBox122 = (TextBox)TabPage3.FindControl("txtTextBox122");
            //                        money = Convert.ToInt32(txtTextBox122.Text) + money;
            //                    }
            //                }
            //                TextBox txtTextBox40 = (TextBox)TabPage3.FindControl("txtTextBox40");
            //                if (txtTextBox40.Text=="")
            //                {
            //                    txtTextBox40.Text = money.ToString();
            //                    Page.ClientScript.RegisterStartupScript(this.GetType(), "5", "<script>SetMoneyRelation('txtTextBox40','txtTextBox39')</script>");
            //                }
            //            }
            //        }
            //    }
            //}
            //#endregion
            #endregion
        }

        protected void FuJian_Click(object sender, EventArgs e)
        {
            MPPersistence Persistence1 = (MPPersistence)FindControl("Persistence1");
            if (!string.IsNullOrEmpty(Persistence1.KeyValue))
            {
                string strScript = string.Format("<script>OpenFileUpload('{0}','{1}','{2}','{3}');</script>", "1024",
                    Persistence1.KeyValue, HttpContext.Current.Request["ID"].Trim(), HttpContext.Current.Request["PID"].Trim());
                Page.ClientScript.RegisterStartupScript(this.GetType(), "opennew", strScript);
            }

        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            Panel panel1 = (Panel)FindControl("panel1");
            TabControl tabConreol1 = (TabControl)panel1.FindControl("tabConreol1");
            TabPage TabPage1 = (TabPage)tabConreol1.FindControl("TabPage1");
            TabPage TabPage3 = (TabPage)tabConreol1.FindControl("TabPage3");
            TabPage TabPage6 = (TabPage)tabConreol1.FindControl("TabPage6");
            TextBox txtTextBox5 = (TextBox)TabPage3.FindControl("txtTextBox5");
            TextBox txtTextBox6 = (TextBox)TabPage3.FindControl("txtTextBox6");
            TextBox txtTextBox7 = (TextBox)TabPage3.FindControl("txtTextBox7");
            TextBox txtTextBox8 = (TextBox)TabPage3.FindControl("txtTextBox8");
            TextBox txtTextBox9 = (TextBox)TabPage3.FindControl("txtTextBox9");
            TextBox txtTextBox10 = (TextBox)TabPage3.FindControl("txtTextBox10");
            TextBox txtTextBox11 = (TextBox)TabPage3.FindControl("txtTextBox11");
            TextBox txtTextBox12 = (TextBox)TabPage3.FindControl("txtTextBox12");
            TextBox txtTextBox13 = (TextBox)TabPage3.FindControl("txtTextBox13");
            TextBox txtTextBox14 = (TextBox)TabPage3.FindControl("txtTextBox14");
            //TextBox txtTextBox15 = (TextBox)TabPage3.FindControl("txtTextBox15");
            TextBox txtTextBox16 = (TextBox)TabPage3.FindControl("txtTextBox16");
            TextBox txtIID = (TextBox)panel1.FindControl("txtIID");
            TextBox txtZSJDH = (TextBox)TabPage1.FindControl("txtZSJDH");
            string PERSONID = HttpContext.Current.Request["PERSONID"];
            if (!string.IsNullOrEmpty(PERSONID))
            {
                EluZSProvider.ZSPERSON zsperson = _EluZSDataProvider.GetZSPERSON(PERSONID);
                if (string.IsNullOrEmpty(txtTextBox6.Text)) { txtTextBox6.Text = zsperson.产权人; }
                if (string.IsNullOrEmpty(txtTextBox12.Text)) { txtTextBox12.Text = zsperson.房屋坐落; }
                if (string.IsNullOrEmpty(txtTextBox13.Text)) { txtTextBox13.Text = zsperson.产权人; }
                if (string.IsNullOrEmpty(txtTextBox14.Text)) { txtTextBox14.Text = zsperson.承租人; }
                if (string.IsNullOrEmpty(txtTextBox7.Text)) { txtTextBox7.Text = zsperson.承租人; }
            }
            string strPNID = HttpContext.Current.Request["PID"];
            if (!string.IsNullOrEmpty(strPNID))
            {
                EluZSProvider.Prono prono = _EluZSDataProvider.GetProno(strPNID);
                if (!string.IsNullOrEmpty(prono.PID))
                {
                    EluZSProvider.Project project = _EluZSDataProvider.GetProjectXX(prono.PID);
                    if (string.IsNullOrEmpty(txtTextBox5.Text)) { txtTextBox5.Text = project.征收部门; }
                    if (string.IsNullOrEmpty(txtTextBox11.Text)) { txtTextBox11.Text = project.区属; }
                   // if (string.IsNullOrEmpty(txtTextBox15.Text)) { txtTextBox15.Text = ""; }
                    if (string.IsNullOrEmpty(txtTextBox16.Text)) { txtTextBox16.Text = project.评估机构; }
                }
                string myzs = prono.征收许可证号;
                if (string.IsNullOrEmpty(txtZSJDH.Text)) { txtZSJDH.Text = myzs; }
                string tt1 = myzs.Replace("宁", "|");
                string tt2 = tt1.Replace("府征字（", "|");
                string tt3 = tt2.Replace("年第", "|");
                string tt4 = tt3.Replace("号）", "|");
                string tt5 = tt4.Replace("|", ",");
                String[] tt6 = tt5.Split(',');
                if (tt6.Length > 1)
                {
                    if (string.IsNullOrEmpty(txtTextBox8.Text)) { txtTextBox8.Text = tt6[1]; }
                    if (string.IsNullOrEmpty(txtTextBox9.Text)) { txtTextBox9.Text = tt6[2]; }
                    if (string.IsNullOrEmpty(txtTextBox10.Text)) { txtTextBox10.Text = tt6[3]; }
                }
            }
            if (string.IsNullOrEmpty(txtTextBox5.Text))
            {
                ImageButton1.Visible = false;
                Button2.Visible = false;
                Button1.Visible = false;
                Button3.Visible = false;
                LinkButton1.Visible = false;
            }
        }
        protected void BindData()
        {
            string strID = base.Page.Request["ID"];
            if (string.IsNullOrEmpty(strID))
            {
                Label1.Visible = false;
                Label2.Visible = false;
                ImageButton1.Visible = false;
                Button1.Visible = false;
                Button2.Visible = false;
                Button3.Visible = false;
                Button4.Visible = false;
                LinkButton1.Visible = false;
                btnUpload.Visible = false;
                btndel.Visible = false;
            }
            else
            {

                if (_EluZSDataProvider.IsQZSBM(userid) && !_EluZSDataProvider.IsSZSB(userid) && !_EluZSDataProvider.IsNetZSAdmin(userid) && !_EluZSDataProvider.IsZSAdmin(userid))
                {
                    Button7.Visible = false;
                    Button1.Visible = false;
                    LinkButton1.Visible = false;
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "displaytr", "<script>displaytr();</script>");
                }
                if (_EluZSDataProvider.IsQXLRRY(userid))
                {
                    Button7.Visible = false;
                    Button3.Visible = false;
                    Button2.Visible = false;
                    Button1.Visible = false;
                    LinkButton1.Visible = false;
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "displaytr", "<script>displaytr();</script>");
                }
                if (_EluZSDataProvider.IsQXZZ(userid))
                {
                    Button7.Visible = false;
                    Button1.Visible = false;
                    LinkButton1.Visible = false;
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "displaytr", "<script>displaytr();</script>");
                }
                if (_EluZSDataProvider.IsSZSB(userid))
                {
                    btn_zddr.Visible = false;
                    Button4.Visible = false;
                    Button3.Visible = false;
                    Button2.Visible = false;
                    btn_Insert.Visible = false;
                }
                if (_EluZSDataProvider.IsSZSB(userid) || _EluZSDataProvider.IsZSAdmin(userid) || _EluZSDataProvider.IsNetZSAdmin(userid))
                {
                    DataTable strSSHZT = _EluZSDataProvider.GetTable("Select 审核状态,提交备案,市备案状态 From zs_hbhxy t Where Id='" + strID + "'");

                    if (strSSHZT.Rows.Count > 0)
                    {
                        if (strSSHZT.Rows[0]["审核状态"].ToString().Equals("1") && strSSHZT.Rows[0]["提交备案"].ToString().Equals("1") && strSSHZT.Rows[0]["市备案状态"].ToString().Equals("0"))
                        {
                            Button7.Enabled = true;
                            Button7.Text = "备案未通过";
                        }
                        if (strSSHZT.Rows[0]["审核状态"].ToString().Equals("1") && strSSHZT.Rows[0]["提交备案"].ToString().Equals("1") && strSSHZT.Rows[0]["市备案状态"].ToString().Equals("1"))
                        {
                            Button7.Enabled = true;
                            Button7.Text = "备案已通过";
                        }
                        if (!strSSHZT.Rows[0]["审核状态"].ToString().Equals("1") || !strSSHZT.Rows[0]["提交备案"].ToString().Equals("1"))
                        {
                            Button7.Enabled = false;
                            Button7.Text = "备案未通过";
                        }
                    }

                }
                string strTJZT = _EluZSDataProvider.GetString("Select 审核状态 From zs_hbhxy t Where Id='" + strID + "'");
                string strBAZT = _EluZSDataProvider.GetString("Select 提交备案 From zs_hbhxy t Where Id='" + strID + "'");
                if (strTJZT == "0")
                {
                    Label1.Text = "附件上传";
                    btnUpload.Text = "附件上传";
                    btn_Insert.Enabled = true;
                    Button4.Enabled = true;
                    Button3.Enabled = false;
                    Button2.Enabled = false;
                    Button1.Enabled = false;
                }
                else if (strTJZT == "1")
                {
                    Label1.Text = "附件列表";
                    btnUpload.Text = "附件列表";
                    btn_Insert.Enabled = false;
                    Button4.Enabled = false;
                    Button3.Enabled = true;
                    Button2.Enabled = true;
                    Button1.Enabled = false;

                    if (strBAZT == "0")
                    {
                        Label1.Text = "附件列表";
                        btnUpload.Text = "附件列表";
                        btn_Insert.Enabled = false;
                        Button4.Enabled = false;
                        Button3.Enabled = true;
                        Button2.Enabled = true;
                        Button1.Enabled = false;
                    }
                    else if (strBAZT == "1")
                    {
                        Label1.Text = "附件列表";
                        btnUpload.Text = "附件列表";
                        btn_Insert.Enabled = false;
                        Button4.Enabled = false;
                        Button3.Enabled = false;
                        Button2.Enabled = false;
                        Button1.Enabled = true;
                    }
                }
                string strth = _EluZSDataProvider.GetString("Select 是否退回 From zs_hbhxy t Where Id='" + strID + "'");
                if (strth.ToString() == "1")
                {
                    btndel.Text = "已退回";
                    btn_Insert.Visible = false;
                    Button4.Visible = false;
                    Button3.Visible = false;
                    Button2.Visible = false;
                    Button1.Visible = false;
                    Button7.Visible = false;
                }
            }
        }
        protected void btn_Insert_Click(object sender, EventArgs e)
        {
            Panel panel1 = (Panel)FindControl("panel1");
            TabControl tabConreol1 = (TabControl)panel1.FindControl("tabConreol1");
            TabPage TabPage1 = (TabPage)tabConreol1.FindControl("TabPage1");
            TabPage TabPage3 = (TabPage)tabConreol1.FindControl("TabPage3");
            TabPage TabPage5 = (TabPage)tabConreol1.FindControl("TabPage5");
            TabPage TabPage8 = (TabPage)tabConreol1.FindControl("TabPage8");
            TabPage TabPage9 = (TabPage)tabConreol1.FindControl("TablePage9");
            //自动生成合同号
            TextBox TextBox1 = (TextBox)TabPage1.FindControl("txtTextBox1");
            if (TextBox1.Text.Trim() =="")
            {


                string sql1 = @"Select (Case When length(to_char(nvl(Max(最大顺序号),0)*1+1))=1 Then 
                            '000'||to_char(nvl(Max(最大顺序号),0)*1+1) 
                            When length(nvl(Max(最大顺序号),0)*1+1)=2 Then 
                            '00'||to_char(nvl(Max(最大顺序号),0)*1+1) 
                            When length(nvl(Max(最大顺序号),0)*1+1)=3 Then 
                            '0'||to_char(nvl(Max(最大顺序号),0)*1+1) 
                            Else to_char(nvl(Max(最大顺序号),0)*1+1) End
                            ) 顺序号
                            From (Select Max(最大顺序号) 最大顺序号 From 
                            (Select Max(textbox1) 最大顺序号 From zs_hbhxy 
                             Where  pnid ='" + Page.Request["PID"] + @"'
                             Union All 
                             Select Max(textbox2) 最大顺序号 From zs_cqzhxy 
                             Where fid In (
                             Select Id From zs_proloupan Where pid In(Select pid From zs_prono Where id='" + Page.Request["PID"] + "'))))";
                string num = _EluZSDataProvider.GetString(sql1);
                TextBox1.Text = num;
            }


            for (int i = 0; i < TabPage3.Controls.Count; i++)
            {
                if (TabPage3.Controls[i] is TextBox)
                {
                    if ((TabPage3.Controls[i] as TextBox).Text == "")
                    {
                        (TabPage3.Controls[i] as TextBox).Text = "\\";
                    }
                }
            }
            for (int i = 0; i < TabPage5.Controls.Count; i++)
            {
                if (TabPage5.Controls[i] is TextBox)
                {
                    if ((TabPage5.Controls[i] as TextBox).Text == "")
                    {
                        (TabPage5.Controls[i] as TextBox).Text = "\\";
                    }
                }
            }
            for (int i = 0; i < TabPage9.Controls.Count; i++)
            {
                if (TabPage9.Controls[i] is TextBox)
                {
                    if ((TabPage9.Controls[i] as TextBox).Text == "")
                    {
                        (TabPage9.Controls[i] as TextBox).Text = "\\";
                    }
                }
            }
            for (int i = 0; i < TabPage8.Controls.Count; i++)
            {
                if (TabPage8.Controls[i] is TextBox)
                {
                    if ((TabPage8.Controls[i] as TextBox).Text == "")
                    {
                        (TabPage8.Controls[i] as TextBox).Text = "\\";
                    }
                }
            }
   
            MPPersistence Persistence1 = (MPPersistence)FindControl("Persistence1");
            Persistence1.Update();

            HttpContext.Current.Response.Redirect("HuoBiHuaBuChangXieYi.aspx?ID=" + Persistence1.KeyValue + "&PID=" + HttpContext.Current.Request["PID"] + "&PERSONID=" + HttpContext.Current.Request["PERSONID"]);
        }
        /// <summary>
        /// 协议附件上传
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            MPPersistence Persistence1 = (MPPersistence)FindControl("Persistence1");
            if (!string.IsNullOrEmpty(Persistence1.KeyValue))
            {
                string strScript = string.Format("<script>OpenFileUpload('{0}','{1}','{2}','{3}');</script>", "102",
                    Persistence1.KeyValue, HttpContext.Current.Request["ID"].Trim(), HttpContext.Current.Request["PID"].Trim());
                Page.ClientScript.RegisterStartupScript(this.GetType(), "opennew", strScript);
            }
        }
        
        /// <summary>
        /// 其他附件上传
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button5_Click(object sender, EventArgs e)
        {
            MPPersistence Persistence1 = (MPPersistence)FindControl("Persistence1");
            if (!string.IsNullOrEmpty(Persistence1.KeyValue))
            {
                string strScript = string.Format("<script>OpenFileUpload('{0}','{1}','{2}','{3}');</script>", "1021",
                    Persistence1.KeyValue, HttpContext.Current.Request["ID"].Trim(), HttpContext.Current.Request["PID"].Trim());
                Page.ClientScript.RegisterStartupScript(this.GetType(), "opennew", strScript);
            }
        }
        /// <summary>
        /// 其他附件上传
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button6_Click(object sender, EventArgs e)
        {
            MPPersistence Persistence1 = (MPPersistence)FindControl("Persistence1");
            if (!string.IsNullOrEmpty(Persistence1.KeyValue))
            {
                string strScript = string.Format("<script>OpenFileUpload('{0}','{1}','{2}','{3}');</script>", "1022",Persistence1.KeyValue, HttpContext.Current.Request["ID"].Trim(), HttpContext.Current.Request["PID"].Trim());Page.ClientScript.RegisterStartupScript(this.GetType(), "opennew", strScript);
            }
        }
        
        /// <summary>
        /// 打印按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ImageButton1_Click(object sender, EventArgs e)
        {
            string strID = HttpContext.Current.Request["id"];
            if (!string.IsNullOrEmpty(strID))
            {
                int tt = Convert.ToInt32(_EluZSDataProvider.GetSomeStr("zs_hbhxy", "打印次数", "id", strID));
                string temp = (tt + 1).ToString();
                _EluZSDataProvider.UpdateSomething("zs_hbhxy", "打印次数", temp, "id", strID);
                _EluZSDataProvider.InsertSomething("ZS_XYDYRY", "xyid,userid,type", string.Format("'{0}','{1}','1'", strID, userid));
                string strScript = string.Format("<script>openPrint('{0}');</script>", HttpContext.Current.Request["id"], strID);
                Page.ClientScript.RegisterStartupScript(this.GetType(), "openPrint", strScript);
            }
        }
        /// <summary>
        /// 打印人员留痕
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void linkButton1_Click(object sender, EventArgs e)
        {
            HttpContext.Current.Response.Redirect("ZS_DYRYLH.aspx?PID=" + HttpContext.Current.Request["PID"] + "&PERSONID=" + HttpContext.Current.Request["PERSONID"] + "&ID=" + HttpContext.Current.Request["ID"] + "&query=hbhbc&type=1");
        }

        /// <summary>
        /// 提交审核
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button4_Click(object sender, EventArgs e)
        {
            string strID = base.Page.Request["ID"];
            string strPID = base.Page.Request["PID"];
            _EluZSDataProvider.GetProjectZT("zs_hbhxy", "审核状态", strID, "1"); 
            if (_EluZSDataProvider.CkFileCount(strPID, "102")) { _EluZSDataProvider.UpdateFileCS(strPID, "102"); }
            if (_EluZSDataProvider.CkFileCount(strPID, "1021")) { _EluZSDataProvider.UpdateFileCS(strPID, "1021"); }
            if (_EluZSDataProvider.CkFileCount(strPID, "1022")) { _EluZSDataProvider.UpdateFileCS(strPID, "1022"); }
            Label1.Text = "附件列表";
            btnUpload.Text = "附件列表";
            btn_Insert.Enabled = false;
            Button4.Enabled = false;
            Button3.Enabled = true;
            Button2.Enabled = true;
            Button1.Enabled = false;
            Button7.Enabled = false;

        }
        /// <summary>
        /// 撤销提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void button3_Click(object sender, EventArgs e)
        {
            string strID = base.Page.Request["ID"];
            _EluZSDataProvider.GetProjectZT("zs_hbhxy", "审核状态", strID, "0");
            Label1.Text = "附件上传";
            btnUpload.Text = "附件上传";
            btn_Insert.Enabled = true;
            Button4.Enabled = true;
            Button3.Enabled = false;
            Button2.Enabled = false;
            Button1.Enabled = false;
            Button7.Enabled = false;
        }
        /// <summary>
        /// 提交备案事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnTijiao_Click(object sender, EventArgs e)
        {
            string strID = base.Page.Request["ID"];
            _EluZSDataProvider.GetProjectZT("zs_hbhxy", "提交备案", strID, "1");
//            string sql = @"Update Zs_Hbhxy
//   Set 备案时间 = to_date('" + DateTime.Now + "',' Yyyy - Mm - Dd Hh24 :Mi :Ss '),TextBox2 = '" + DateTime.Now.Year + "',TextBox3 = '" + DateTime.Now.Month + "',TextBox4 = '" + DateTime.Now.Day + "' Where Id = '" + strID + "'";
//            _EluZSDataProvider.RunSqlNon(sql);
            Label1.Text = "附件列表";
            btnUpload.Text = "附件列表";
            btn_Insert.Enabled = false;
            Button4.Enabled = false;
            Button3.Enabled = false;
            Button2.Enabled = false;
            Button1.Enabled = true;
            Button7.Enabled = true;
            
        }
        /// <summary>
        /// 撤销备案事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void button1_Click(object sender, EventArgs e)
        {
            string strID = base.Page.Request["ID"];
            _EluZSDataProvider.GetProjectZT("zs_hbhxy", "提交备案", strID, "0");
            string sql = @"Update Zs_Hbhxy set TextBox2 = ' ',TextBox3 = ' ',TextBox4 = ' ' Where Id = '" + strID + "'";
            _EluZSDataProvider.RunSqlNon(sql);
            Label1.Text = "附件列表";
            btnUpload.Text = "附件列表";
            btn_Insert.Enabled = false;
            Button4.Enabled = false;
            Button3.Enabled = true;
            Button2.Enabled = true;
            Button1.Enabled = false;
            Button7.Enabled = false;
            Page.ClientScript.RegisterStartupScript(this.GetType(), "up1", "<script>location.href = location.href;</script>");
        }

        /// <summary>
        /// 审核状态
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button7_Click(object sender, EventArgs e)
        {
            string strID = base.Page.Request["ID"];
            if (Button7.Text == "备案已通过")
            {
                _EluZSDataProvider.GetProjectZT("zs_hbhxy", "市备案状态", strID, "0");
                Button7.Text = "备案未通过";
                return;
            }
            if (Button7.Text == "备案未通过")
            {
                _EluZSDataProvider.GetProjectZT("zs_hbhxy", "市备案状态", strID, "1");
                Button7.Text = "备案已通过";
                Panel panel1 = (Panel)FindControl("panel1");
                TabControl tabConreol1 = (TabControl)panel1.FindControl("tabConreol1");
                TabPage TabPage1 = (TabPage)tabConreol1.FindControl("TabPage1");
                TextBox txtTextBox2 = (TextBox)TabPage1.FindControl("txtTextBox2");
                if (string.IsNullOrEmpty(txtTextBox2.Text.Trim()))
                {
                    txtTextBox2.Text = System.DateTime.Now.Year.ToString();
                }
                TextBox txtTextBox3 = (TextBox)TabPage1.FindControl("txtTextBox3");
                if (string.IsNullOrEmpty(txtTextBox3.Text.Trim()))
                {
                    txtTextBox3.Text = System.DateTime.Now.Month.ToString();
                }
                TextBox txtTextBox4 = (TextBox)TabPage1.FindControl("txtTextBox4");
                if (string.IsNullOrEmpty(txtTextBox4.Text.Trim()))
                {
                    txtTextBox4.Text = System.DateTime.Now.Day.ToString();
                }
                Page.ClientScript.RegisterStartupScript(this.GetType(), "up", "<script>location.href = location.href;</script>");
            }
        }
    }
}


